package com.igeek.collateral.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.igeek.collateral.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.Set;

/**
 * <p>
 * 用户表 Mapper 接口
 *
 *   ${ew.customSqlSegment}:拼接where后的语询(在动态sq|中请勿处于标签内)
 *   ${ew.sqlSelect} :拼接select SQL主体
 *   ${ew.sqlSet} :拼接update主体
 *   ${ew.sqlSegment} :拼接where后的语询
 *
 * </p>
 *
 * @author author
 * @since 2024-07-04
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user ${ew.customSqlSegment}")
    @Results({
            @Result(id = true , column = "id" , property = "id"),
            @Result(column = "id" , property = "roles" , javaType = Set.class ,
                    many = @Many(select = "com.igeek.collateral.mapper.RoleMapper.selectRolesByUserId"))
    })
    Page<User> selectAllPage(@Param("page") Page<User> page,  @Param("ew") LambdaQueryWrapper<User> lambdaQueryWrapper);
}
